import { get, post } from '@/utils/http'
import type {
  GetSupplierFormListResult,
  GetSupplierStatusCountResult,
  CreateSupplierFormParams,
  GetSupplierFormDetailResult
} from './model/supplierModel'

import type { BasicPagingListResult, BasicPagingListParams } from '@/apis/basicModel'

enum Api {
  // 供应商数据集分页
  GET_SUPPLIER_FORM_LIST = '/footprint/supplier/form/pageForm',
  // 供应商数据集状态计数
  GET_SUPPLIER_STATUS_COUNT = '/footprint/supplier/form/countFormStatus',
  // 创建供应商表单
  CREATE_SUPPLIER_FORM = '/footprint/supplier/form/createForm',
  // 获取供应商数据集信息
  GET_SUPPLIER_FORM_DETAIL = '/footprint/supplier/form/getForm'
}

// 供应商数据集分页
export const getSupplierFormList = (
  params: BasicPagingListParams & { status: string }
): Promise<BasicPagingListResult<GetSupplierFormListResult>> =>
  get(Api.GET_SUPPLIER_FORM_LIST, params)

// 供应商数据集状态计数
export const getSupplierStatusCount = (): Promise<GetSupplierStatusCountResult> =>
  get(Api.GET_SUPPLIER_STATUS_COUNT)

// 创建供应商表单
export const createSupplierForm = (params: CreateSupplierFormParams): Promise<string> =>
  post(Api.CREATE_SUPPLIER_FORM, params)

// 获取供应商数据集信息
export const getSupplierFormDetail = (formNo: string): Promise<GetSupplierFormDetailResult> =>
  get(Api.GET_SUPPLIER_FORM_DETAIL, { formNo })
